#ifndef __COND_HPP__
#define __COND_HPP__
#include <iostream>
#include <pthread.h>
#include "Mutex.hpp"

namespace wxd
{
    class Cond
    {
    public:
    Cond()
    {
        //初始化条件变量
        pthread_cond_init(&_cond,nullptr);
    }   
    ~Cond()
    {
        pthread_cond_destroy(&_cond);
    }
    void Wait(Mutex& mutex)
    {
        pthread_cond_wait(&_cond,mutex.Get());
    }
    void Signal()
    {
        pthread_cond_signal(&_cond);
    }
    void BroadCast()
    {
        pthread_cond_broadcast(&_cond);
    }
    private:
    pthread_cond_t _cond;
    };
}

#endif